package com.zy.explore.file.interfaces.feign;

import com.zy.explore.common.interfaces.vo.ResultVO;
import com.zy.explore.file.infrastructure.constant.MinioRouter;
import com.zy.explore.file.infrastructure.constant.OssRouter;
import com.zy.explore.file.infrastructure.constant.ProjectConstant;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;


/**
 * 建类说明：oss feign服务
 *
 * @author 中国印
 * @date 2022年01月28日 23:23:57
 */
@FeignClient(name = ProjectConstant.APPLICATION_NAME, path = OssRouter.OSS, contextId = ProjectConstant.APPLICATION_NAME + ".OssFeign")
public interface OssFeign {

    /**
     * 方法说明：上传Multipart文件到OSS返回访问地址
     *
     * @param file 文件
     * @return {@link ResultVO<String> }
     * @throws Exception 异常
     */
    @ApiOperation("上传MultipartFile至OSS返回下载地址")
    @PostMapping(value = OssRouter.UPLOAD, headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResultVO<String> upload(@RequestPart("file") MultipartFile file) throws Exception;


    /**
     * 方法说明：上传字节流文件到OSS返回访问地址
     *
     * @param file 文件
     * @return {@link ResultVO<String> }
     * @throws Exception 异常
     */
    @ApiOperation("上传MultipartFile至OSS返回下载地址(流式上传)")
    @PostMapping(value = OssRouter.UPLOAD_BY_BYTES, headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResultVO<String> uploadByBytes(@RequestPart("file") MultipartFile file) throws Exception;



}
